package com.ziyun.erp.web.modules.service.controller;

import com.ziyun.erp.modules.service.entity.ServiceRegisterLogEntity;
import com.ziyun.erp.modules.service.service.ServiceRegisterLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 售后订单日志表
 *
 * @author zh
 * @email 296588519@qq.com
 * @date 2018-08-28 15:41:42
 */
@RestController
@RequestMapping("service/serviceregisterlog")
public class ServiceRegisterLogController {
    @Autowired
    private ServiceRegisterLogService serviceRegisterLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("service:serviceregisterlog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = serviceRegisterLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{srlId}")
    @RequiresPermissions("service:serviceregisterlog:info")
    public R info(@PathVariable("srlId") Integer srlId){
        ServiceRegisterLogEntity serviceRegisterLog = serviceRegisterLogService.selectById(srlId);

        return R.ok().put("serviceRegisterLog", serviceRegisterLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("service:serviceregisterlog:save")
    public R save(@RequestBody ServiceRegisterLogEntity serviceRegisterLog){
        serviceRegisterLogService.insert(serviceRegisterLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("service:serviceregisterlog:update")
    public R update(@RequestBody ServiceRegisterLogEntity serviceRegisterLog){
        ValidatorUtils.validateEntity(serviceRegisterLog);
        serviceRegisterLogService.updateAllColumnById(serviceRegisterLog);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("service:serviceregisterlog:delete")
    public R delete(@RequestBody Integer[] srlIds){
        serviceRegisterLogService.deleteBatchIds(Arrays.asList(srlIds));

        return R.ok();
    }

}
